package code;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class OneStepOrder {
	/*
	 * �ղ���
	 */
	class Order{
		String shopName;
		String Item;
		double price;
		int number;
		public Order(){
			//...��ʼ���ղ���
		}
		public double sum(){
			return price*number;
		}
	}
	/*
	 * ���ﳵ��
	 */
	class ShoppingCar{
		private List<Order> orders;
		
		public ShoppingCar(){
			//��������ʼ�����ﳵ
		}
		public void add(Order or){
			orders.add(or);
		}
		public void delete(Order or){
			orders.remove(or);
		}
		public double buyAll(){
			double sumAll=0;
			for(int i=0;i<orders.size();i++){
				sumAll+=((Order)orders.get(i)).sum();
			}
			orders.clear();
			return sumAll;
		}
		public List<Order> getOrder(){
			return orders;
		}
 	}
	class Customer{
		private String user;
		private ShoppingCar shoppingCar;
		
		public Customer(){
			//��ʼ��
		}
		public Customer buy(){
			return this;
		}
	}
	/*
	 * �������˴����µ��������
	 */
	class ServerAutoOrder{
		private List<Customer> customer=new ArrayList<Customer>();
		
		private static final int servThreads=10;
		
		private ExecutorService es=Executors.newFixedThreadPool(servThreads);
		
		/*
		 * ����ͻ����������Ҫ�߼�����
		 */
		public void DealCustomerOrder(){
			while(true){
				es.execute(new Runnable(){
	
					@Override
					public void run() {
						// TODO Auto-generated method stub
						/*ʵ���µ��Ĺ���
						* deal(customer);
						*/
					}
					
				});
			}
			/*
			 * ��û�û������ʱ���˳�
			 */
		}
	}
	
	/*
	 * �û���
	 */
	class User{
		private String id;
		
//		public void makeOrder(FourS four,Suit suit){
//			return Order(this,four,suit);
//		}
	}
	/*
	 * 4s����
	 */
	class FourS{
		private String name;
	}
	/*
	 * �ײ���
	 */
	class Suit{
		private String suitName;
		private int personNumber;
	}
	
//	class Order{
//		private User user;
//		private FourS four;
//		private Suit suit;
//		
//		public Order(User user,FourS four,Suit suit){
//			this.user=user;
//			this.four=four;
//			this.suit=suit;
//		}
//	}
	/*
	 * �������ϵͳ����
	 */
	class CarServerSystem{
		/*
		 * ���û���4s�ꡢ�ײ����͡��û����������
		 * ���ж���ݵĲ���
		 */
		private List<User> users=new ArrayList<User>();
		private List<FourS> fours=new ArrayList<FourS>();
		
		private List<Order> orders=new ArrayList<Order>();
		
		private List<Suit> suit=new ArrayList<Suit>();
		
		public void Order(Order order){
			orders.add(order);
		}
		//todo...
	}

}
